package trouger.dmt;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;

/**
 * 
 * The interface whose implementation class instance should do the main logic process of the map phase,
 * accepting each record and then give a key-value pair.
 * 
 * @param <K> the map-output-key class, must implement {@link WritableComparable}
 * @param <V> the map-output-value class, must implement {@link Writable}
 */
interface MapperEntity<K, V> {
	/**
	 * Accept one record. 
	 * @param sourceIndex zero-based index of the source table of the incoming record.
	 * @param segment the record, in which segment[1] is the first field value.
	 * @return true if a key-value pair is to be output, otherwise false.
	 */
	public boolean acceptLine(int sourceIndex, String[] segment);
	/**
	 * Give a key. This method should be called together with getValue(), to get a key-value pair.
	 * @return a key if the previous call to acceptLine returns true, or the behavior of this method is undefined.
	 */
	public K getKey();
	/**
	 * Give a value. This method should be called together with getKey(), to get a key-value pair.
	 * @return a value if the previous call to acceptLine returns true, or the behavior of this method is undefined.
	 */
	public V getValue();
}
